// CustomPalette.js
export default class CustomPalette {  //创建一个类 继承
    constructor( create, elementFactory, palette) {
        this.create = create;
        this.elementFactory = elementFactory;
        palette.registerProvider(this);
    }
    getPaletteEntries(element) {
        console.log('element---->',element);
        const {
            create,
            elementFactory,
        } = this;

        function createTask() {
            return function(event) {
                const shape = elementFactory.createShape({
                    type: 'bpmn:StartEvent',
                });
                // console.log(shape) // 只在拖动或者点击时触发
                create.start(event, shape);
            }
        }

        return {
            'create.lindaidai-task': {
                className: 'icon-custom lindaidai-task',
                action: {
                    dragstart: createTask(),
                    click: createTask()
                }
            }
        }
    }
}

CustomPalette.$inject = [
    'create',
    'elementFactory',
    'palette',
]
